package com.hjm.project.bankResponsedata.bankResponsedata.controller;

import java.util.List;

import com.hjm.common.utils.Utils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.bankResponsedata.bankResponsedata.domain.BankResponsedata;
import com.hjm.project.bankResponsedata.bankResponsedata.service.IBankResponsedataService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 渠道应答Controller
 * 
 * @author LOVE
 * @date 2020-11-27
 */
@Controller
@RequestMapping("/bankResponsedata/bankResponsedata")
public class BankResponsedataController extends BaseController
{
    private String prefix = "bankResponsedata/bankResponsedata";

    @Autowired
    private IBankResponsedataService bankResponsedataService;

    @RequiresPermissions("bankResponsedata:bankResponsedata:view")
    @GetMapping()
    public String bankResponsedata()
    {
        return prefix + "/bankResponsedata";
    }

    /**
     * 查询渠道应答列表
     */
    @RequiresPermissions("bankResponsedata:bankResponsedata:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BankResponsedata bankResponsedata)throws Exception
    {
        startPage();
        List<BankResponsedata> list = bankResponsedataService.selectBankResponsedataList(bankResponsedata);
        for(int i=0;i<list.size();i++){
            list.get(i).setPan(Utils.dealCard(list.get(i).getPan()));
        }
        return getDataTable(list);
    }

    /**
     * 导出渠道应答列表
     */
    @RequiresPermissions("bankResponsedata:bankResponsedata:export")
    @Log(title = "渠道应答", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BankResponsedata bankResponsedata)
    {
        List<BankResponsedata> list = bankResponsedataService.selectBankResponsedataList(bankResponsedata);
        ExcelUtil<BankResponsedata> util = new ExcelUtil<BankResponsedata>(BankResponsedata.class);
        return util.exportExcel(list, "bankResponsedata");
    }

    /**
     * 新增渠道应答
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存渠道应答
     */
    @RequiresPermissions("bankResponsedata:bankResponsedata:add")
    @Log(title = "渠道应答", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BankResponsedata bankResponsedata)
    {
        return toAjax(bankResponsedataService.insertBankResponsedata(bankResponsedata));
    }

    /**
     * 修改渠道应答
     */
    @GetMapping("/edit/{serial}")
    public String edit(@PathVariable("serial") Long serial, ModelMap mmap)
    {
        BankResponsedata bankResponsedata = bankResponsedataService.selectBankResponsedataById(serial);
        mmap.put("bankResponsedata", bankResponsedata);
        return prefix + "/edit";
    }

    /**
     * 修改保存渠道应答
     */
    @RequiresPermissions("bankResponsedata:bankResponsedata:edit")
    @Log(title = "渠道应答", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BankResponsedata bankResponsedata)
    {
        return toAjax(bankResponsedataService.updateBankResponsedata(bankResponsedata));
    }

    /**
     * 删除渠道应答
     */
    @RequiresPermissions("bankResponsedata:bankResponsedata:remove")
    @Log(title = "渠道应答", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bankResponsedataService.deleteBankResponsedataByIds(ids));
    }
}
